Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add clang as a common build tool #608

Merged
merged 4 commits into from
Mar 14, 2022
Merged

add clang as a common build tool #608

merged 4 commits into from
Mar 14, 2022

Conversation

anatawa12
Copy link
Contributor

@anatawa12 anatawa12 commented Nov 9, 2021

Closes #174

This PR adds clang as a common build tool.
The libclang will be used by bindgen so It's better to have clang on all platforms so I add to common.sh

This works for bindgen for the following targets with ffmpeg-next of libavformat, libavcodec, and libavutil with my built ffmpeg binaries:

  • x86_64-pc-windows-gnu
  • x86_64-unknown-linux-musl

I couldn't test x86_64-unknown-linux-gnu because of #455

#455 error message. This will be happened without this PR (with the image from DockerHub)
   Compiling libc v0.2.107
   Compiling ffmpeg-sys-next v4.4.0
error: failed to run custom build command for `libc v0.2.107`

Caused by:
  process didn't exit successfully: `/target/release/build/libc-e4387d0c49bcd20f/build-script-build` (exit status: 1)
  --- stderr
  /target/release/build/libc-e4387d0c49bcd20f/build-script-build: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /target/release/build/libc-e4387d0c49bcd20f/build-script-build)
warning: build failed, waiting for other jobs to finish...
error: build failed

@anatawa12 anatawa12 requested review from Dylan-DPC-zz and a team as code owners November 9, 2021 07:48
@michaelsproul
Copy link

I ran into a similar issue while trying to run bindgen under cross but it wasn't fixed by installing clang because cross uses Ubuntu 16.04 which only includes Clang 3.8 (I think I need 3.9+). There's also no PPA available for Clang 3.9 on 16.04:

Mar 28th 2021 - Ubuntu Xenial (16.04) disabled (EOL)

(from https://apt.llvm.org/)

@JEnoch
Copy link

JEnoch commented Nov 19, 2021

I also had issues with Clang 3.8 which is the packaged version for Ubuntu 16.04.
Thus I followed @Nnubes256's suggestion in #257 and made custom images installing Clang 12 and defining appropriate --sysroot option for Clang via BINDGEN_EXTRA_CLANG_ARGS.

If any help the images are available as jenoch/rust-cross and the Dockerfiles are in https://github.com/JEnoch/rust-cross-clang/.

I only made images for ARMs and x86_64+musl so far. I'm not sure if/how what I did can be adapted as a PR in here for all Docker images.

@michaelsproul
Copy link

Thank you @JEnoch!

I can confirm that the same technique works on x86_64 with glibc!

My Docker files are here for reference.

@timstokman
Copy link

To get bindgen working, all I did was use this docker image:

FROM rustembedded/cross:armv7-unknown-linux-gnueabihf-0.2.1

RUN apt-get update && apt-get install --assume-yes libclang-3.9-dev

Just libclang-3.9-dev is enough, no PPA necessary.

@anatawa12
Copy link
Contributor Author

I've changed the library to libclang-dev.

Emilgardis
Emilgardis previously approved these changes Dec 9, 2021
Copy link
Member

@Emilgardis Emilgardis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

However, CI is broken

r=me when fixed

@Emilgardis
Copy link
Member

Remaining errors are due to a timeout also observed in #609

@reitermarkus
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 14, 2022

Build succeeded:

@bors bors bot merged commit 8da2f70 into cross-rs:main Mar 14, 2022
@Emilgardis Emilgardis added this to the v0.2.2 milestone Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Install clang on the windows environments
7 participants